package com.atguigu.day22.work;

import org.junit.Test;

import java.io.*;

public class Work5 {
    @Test
    public void w1() throws IOException {
        int a=10;
        char c='a';
        double d=2.5;
        boolean b=true;
        String str="shangguigu";
        FileOutputStream f1=new FileOutputStream("data.dat");
        DataOutput d1=new DataOutputStream(f1);
        d1.writeInt(a);
        d1.writeChar(c);
        d1.writeDouble(d);
        d1.writeBoolean(b);
        d1.writeUTF(str);
    }
    @Test
    public void w2() throws IOException {
        FileInputStream f1=new FileInputStream("data.dat");
        DataInputStream dis = new DataInputStream(f1);
        System.out.println(dis.readInt());
        System.out.println(dis.readChar());
        System.out.println(dis.readDouble());
        System.out.println(dis.readBoolean());
        System.out.println(dis.readUTF());
        dis.close();
    }
}
